<?php

if (!defined('DIR_SEP'))
    define('DIR_SEP', DIRECTORY_SEPARATOR);

if (!defined('MODULES_DIR'))
    define('MODULES_DIR', dirname(__FILE__).DIR_SEP."..".DIR_SEP);

require_once(MODULES_DIR."IManager.inc");
require_once(MODULES_DIR."log.inc");
require_once(MODULES_DIR."config.inc");
require_once(MODULES_DIR."util.inc");
require_once(MODULES_DIR."tag.inc");
require_once(MODULES_DIR."blogRoll".DIR_SEP."blogRoll.inc");

class BlogRollManager implements IManager
{
	public function getAdminMenu()
	{
		//get admin menu should be deprecated, and managed in get admin menu.
		//should be managed in settings page, add tab for blog settings
		global $G_HOME;
		return "<li class='navCategory'>Manage Blog Roll</li>
			<li class='navItem'><a href='".Util::combinePath($G_HOME,"index.php?pg=add_post")."'>Add post</a></li>";
	}
	
	public function getMenu()
	{
		global $G_HOME;
		
		$result = "<li class='navCategory'>Recommended sites</li>";
		
		$blogRollLinks = BlogRoll::getAll();
		
		foreach($blogRollLinks as $row)
		{
			$follow = $row['allow_follow'] == "0" ? "rel='nofollow'" : "";
			$target = $row['open_window'] == "1" ? "target='_blank'" : "";
			
			$result .= "<li class='navItem'>";
			
			$link = "<a style='display:inline;padding:0;margin:0' ".$target." ".$follow." title='".$row["title"]."' href='".$row["url"]."'>".$row["content"]."</a>";
			
			$result .= str_replace("{0}",$link,$row['paragraph'])."</li>";
		}
		return $result;
	}
}

?>